#include "stdafx.h"
#include <serialization/ioParamStructs.h>
#include <serialization/serialization.h>
#include <memory>
#include <winsock/winsock_stub.h>

void send_stub (
    __in  std::vector<char>& in_buf,
    __out std::vector<char>& out_buf
    )
{
//RECEIVE()
    Deserialize deserialize (in_buf);
    send_in_inout sendIN;
    deserialize (sendIN);

    int ret = send (sendIN.s_, sendIN.buf_, sendIN.len_, sendIN.flags_ );
//SEND
    send_out_inout sendOUT( ret, WSAGetLastError() );
    
    Serialize(deserialize.get_header(), sendOUT, out_buf);
}

void sendto_stub (
    __in  std::vector<char>& in_buf,
    __out std::vector<char>& out_buf
    )
{
//RECEIVE()
    Deserialize deserialize (in_buf);
    sendto_in_inout sendtoIN;
    deserialize (sendtoIN);

    int ret = sendto (sendtoIN.s_, sendtoIN.buf_, sendtoIN.len_, 
        sendtoIN.flags_, sendtoIN.to_, sendtoIN.tolen_ );
//SEND
    sendto_out_inout sendtoOUT( ret, WSAGetLastError() );
    
    Serialize(deserialize.get_header(), sendtoOUT, out_buf);
}
